/*
 * @Author: xmily
 * @Date: 2022-02-14 02:12:45
 * @LastEditors: xmily
 * @LastEditTime: 2022-09-19 22:35:35
 * @FilePath: \glxxapi\models\comm\leave.js
 * @Description: 
 * 
 * Copyright (c) 2022 by xmily/mxthink.com.cn, All Rights Reserved. 
 */
//请假（未来学校）库
var mongoose = require('../../cfg/dbconfig.js')

var leaveSchema=new mongoose.Schema({
    schoolname:String,
    term:String,
    date:String,
    classname:String,
    stuname:String,
    stuid:String,
},{collection:'aftclsvr_leave'})

leaveSchema.statics.Save = async function (doc) {
  let obj = new this(doc);
  if (doc._id) {
    obj.isNew = false;
  }
  let res = await obj.save();
  return res;
};


leaveSchema.statics.GetByQuery = async function (query, field, sort) {
    sort = sort || { _id: 1 };
    field = field || {};
    let result = await this.find(query, field).sort(sort).exec();
    return result;
};

leaveSchema.statics.UpdateManyByQuery = async function (
    query,
    update,
    // options
  ) {
    // options = options || { upsert: false, multi: false };
    let result = await this.updateMany(query, update).exec();
    return result;
  };



module.exports = mongoose.model('aftclsvr_leave', leaveSchema)